package com.reggie.common.util;

/**
 * <p>
 * 上下文实现类，
 * 存储当前请求源的用户id和员工id
 * </p>
 * 使用组合而非继承的方式，复用BaseContext类，委托方法
 *
 * @author yth
 * @since 2023-06-10-17:07
 */
public class ReggieContext {

    private static final String EMPLOYEE_ID_PROPERTY_KEY = "employeeId";
    private static final String USER_ID_PROPERTY_KEY = "userId";

    private static final ReggieContext INSTANCE = new ReggieContext();

    public static ReggieContext getInstance() {
        return INSTANCE;
    }

    private ReggieContext() {
    }

    public void setEmployeeId(Long id) {
        CommonContext.getContext().putProperty(EMPLOYEE_ID_PROPERTY_KEY, id);
    }

    public Long getEmployeeId() {
        return (Long) CommonContext.getContext().getProperty(EMPLOYEE_ID_PROPERTY_KEY);
    }

    public void setUserId(Long id) {
        CommonContext.getContext().putProperty(USER_ID_PROPERTY_KEY, id);
    }

    public Long getUserId() {
        return (Long) CommonContext.getContext().getProperty(USER_ID_PROPERTY_KEY);
    }

}
